﻿using Guoc.BigMall.Domain.Entity;
using Guoc.BigMall.Infrastructure.Extension;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Guoc.BigMall.Application.ViewObject
{
    /// <summary>
    ///  分销单
    /// </summary>
   public class DistributeOrderVo
    {

        public DistributeOrderVo() {
            this.Items = new List<DistributeOrderItemVo>();
        }

        public int Id { get; set; }

        public string Code { get; set; }

        public string SaleOrderCode { get; set; }

        public int SaleOrderId { get; set; }

        /// <summary>
        /// 下单会员
        /// </summary>
        public int MemberId { get; set; }

        public string MemberName { get; set; }

        public string MemberPhone { get; set; }

        /// <summary>
        /// 微信昵称
        /// </summary>
        public string NickName { get; set; }
        /// <summary>
        /// 办卡人联系电话
        /// </summary>
        public string ContactPhone { get; set; }
        /// <summary>
        ///  办卡 身份证
        /// </summary>
        public string IdentityCard { get; set; }

        public int ReferMemberId { get; set; }

        public string ReferMemberName { get; set; }

        public string ReferPhone { get; set; }

        public DateTime CreatedOn { get; set; }

        public DateTime UpdatedOn { get; set; }

        public DistributeOrderStatus Status { get; set; }

        public decimal TotalAmount {
            get {
                return this.Items.Sum(n => n.ProfitAmount);
            }
        }

        public string StatusName
        {
            get
            {
                return this.Status.Description();
            }
        }

        public string CreatedOnTime
        {
            get
            {
                return this.CreatedOn.ToString("yyyy-MM-dd HH:mm");
            }
        }

        public IEnumerable<DistributeOrderItemVo> Items { get; set; }

        public IEnumerable<DistributeOrderHistoryVo> Historys { get; set; }


        public bool ShowFinance {
            get{
                return this.Status == DistributeOrderStatus.CanPay && this.Items.Any(n => n.CashStatus == MemberCashStatus.UnCash);
            }
            
        }
    }
}
